<?php 
class UserController extends Controller
{	private $model = null;
	public function __construct(){
	
		parent::__construct();
		$this->model = new Model('u');
	}
	public function index(){
		
		$data = $this->model->select();
		$this->assign('list' , $data);
		$this->assign('title' , '用户首页');
		$this->display('User/index.html');

	}
	public function add(){
		$this->assign('title' ,'添加用户');
		$this->display('User/add.html');
	}
	public function del(){
		if ($this->model->delete($_GET['id'])) {
			$this->redirect('删除成功','./index.php?c=User');
		} else {
			$this->redirect('删除失败','./index.php?c=User');
		}
	}
	public function insert(){
		if ($this->model->insert() > 0) {
			$this->redirect('添加成功','./index.php?c=User');
		}else{
			$this->redirect('添加失败');
		}
	}
	public function edit(){
		$this->assign('title' , '编辑用户');
		$data = $this->model->find($_GET['id']);
		$this->assign('data' , $data);
		$this->display('User/edit.html');
	}
	public function update(){
		if ($this->model->update() ) {
			$this->redirect('更新成功','./index.php?c=User');
		}else{
			$this->redirect('更新失败');
		}
	}

}